local fk__zongshe = fk.CreateSkill {

  name = "fk__zongshe",

  tags = {Skill.Lord},

}

local U = require "packages/utility/utility"


fk__zongshe:addEffect(fk.CardUsing, {
  name = "fk__zongshe$",
  anim_type = "drawcard",
  events = {fk.CardUsing},
  can_trigger = function(self, event, target, player, data)
    return target ~= player and player:hasSkill(fk__zongshe.name) and target.kingdom == "jin" and data.card.type == Card.TypeBasic
    and target:getHandcardNum() >= player:getHandcardNum()
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askForSkillInvoke(player, fk__zongshe.name, nil, "#fk__zongshe-invoke:"..target.id)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:doIndicate(player.id, {target.id})
    local tos = {player.id, target.id}
 
    for _, pid in ipairs(tos) do
      if not room:getPlayerById(pid).dead then
        room:getPlayerById(pid):drawCards(1, fk__zongshe.name)
      end
    end
  end,
})

return fk__zongshe